package com.xing.binbackend.pattern.factory12.largemodel;

import java.util.HashMap;
import java.util.Map;

/**
 * 配置文件 model-mapping.properties
 * bert=com.example.BertLoader
 * gpt=com.example.GPTLoader
 */
public class DynamicModelFactory {
    private static final Map<String, Class<?>> mappings = new HashMap<>();

    static {
        // 读取配置文件加载映射关系
        mappings.put("bert", BertLoader.class);
        mappings.put("gpt", GPTLoader.class);
    }

    public static ModelLoader createLoader(String type) throws Exception {
        Class<?> clazz = mappings.get(type);
        return (ModelLoader) clazz.getDeclaredConstructor().newInstance();
    }
}
